package top.malaoshi.webmvc.info;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

public class MethodsArgumentInfo {

    private MethodInfo methodInfo;
    /**
     * 形参名
     */
    private String name;
    /**
     * 形参类型
     * 如果是数组，那么type为Array
     */
    private Class type;
    /**
     * 当type是数组时，elementType才不为null，表示该数组元素的类型
     */
    private Class elementType;
    /**
     * 形参注解
     */
    private RequestParam requestParam;
    private RequestBody requestBody;

    /**
    形参序号，从0开始
     */
    private int index;

    public MethodsArgumentInfo() {
    }
    public MethodsArgumentInfo(String name, Class type, RequestParam requestParam,int index,MethodInfo mi) {
        this.name = name;
        this.type = type;
        this.requestParam = requestParam;
        this.index = index;
        this.methodInfo = mi;
    }
    public MethodsArgumentInfo(String name, Class type, RequestBody requestBody,int index,MethodInfo mi) {
        this.name = name;
        this.type = type;
        this.requestBody = requestBody;
        this.index = index;
        this.methodInfo = mi;
    }
    public MethodsArgumentInfo(String name, Class type, Class elementType, RequestParam requestParam,int index,MethodInfo mi) {
        this.name = name;
        this.type = type;
        this.elementType = elementType;
        this.requestParam = requestParam;
        this.index = index;
        this.methodInfo = mi;
    }

    public static MethodsArgumentInfo of(String name, Class type, RequestParam requestParam,int index,MethodInfo mi) {
        return new MethodsArgumentInfo(name, type, requestParam,index,mi);
    }
    public static MethodsArgumentInfo of(String name, Class type, RequestBody requestBody, int index, MethodInfo mi) {
        return new MethodsArgumentInfo(name, type, requestBody,index,mi);
    }
    public static MethodsArgumentInfo of(String name, Class type, int index, MethodInfo mi) {
        MethodsArgumentInfo ret = new MethodsArgumentInfo();
        ret.name = name;
        ret.type = type;
        ret.index = index;
        ret.methodInfo = mi;

        return ret;
    }
    public static MethodsArgumentInfo of(String name, Class type, Class elementType, RequestParam requestParam,int index,MethodInfo mi) {
        return new MethodsArgumentInfo(name, type,elementType, requestParam,index,mi);
    }

    public MethodInfo getMethodInfo() {
        return methodInfo;
    }

    public String getName() {
        return name;
    }

    public Class getType() {
        return type;
    }

    public RequestParam getRequestParam() {
        return requestParam;
    }

    public int getIndex() {
        return index;
    }

    public Class getElementType() {
        return elementType;
    }

    public RequestBody getRequestBody() {
        return requestBody;
    }
}
